|
JIRA 4.4 : Plugin Developer Notes for JIRA 5.0
This page last changed on Aug 11, 2011 by mdoar.
On this page:
IntroductionJIRA 5.0 introduces several changes that may break existing plugins which are not bundled with JIRA. If you are using or have been involved in the development of such a plugin, it may need to be updated to work with JIRA 5.0. Please read through the information below to see if any of this content is relevant to your plugin. If you are using a plugin developed by a third party, please check with the plugin's author to see if the plugin has been tested with JIRA 5.0.
Changes to the JIRA API caused by JIRA's upgrade to Lucene 3.2Upgrading to Lucene 3.2 has caused a number of changes to the search interfaces of JIRA. The most notable is the replacement of the HitCollector class by the Collector class. There are also a number of smaller changes. HitCollector replaced by CollectorSearch methods on the com.atlassian.jira.issue.search.SearchProvider class now take a org.apache.lucene.search.Collector where previously they took a HitCollector. If you previously had a class that implemented HitCollector you will need to modify it to implement the Collector interface. For most applications this is simple. See the example below. class NextPreviousHitCollector extends Collector
{
private final List<Integer> docIds = new ArrayList<Integer>();
private int docBase;
NextPreviousHitCollector(final int currentIssueDocId)
{
this.currentIssueDocId = currentIssueDocId;
}
@Override
public void collect(final int i)
{
int doc = docBase + i;
docIds.add(doc);
}
@Override
public void setScorer(Scorer scorer) throws IOException
{
// Do nothing
}
@Override
public void setNextReader(IndexReader reader, int docBase) throws IOException
{
this.docBase = docBase;
}
@Override
public boolean acceptsDocsOutOfOrder()
{
return true;
}
}
The notable points here are that more than one reader may be used by the search and that the document index returned in the collect method is related to the document base of the reader. You need to remember the document base that is set on the call to setNextReader and add this to the value passed in the collect(int i) method. The acceptsDocsOutOfOrder() method should generally return true as the actual ordering of the documents in the index is not relevant to JIRA in any way. You should of course consult the javadocs for the Collect interface. IndexSearcher replaces SearcherThe SearchProviderFactory.getSearcher() method now returns org.apache.lucene.search.IndexSearcher instead of a Searcher. The methods of IndexSearcher are largely compatible with those of the previous searcher interface, but some require an additional parameter specifying how many results you wish to have returned. You can specify Integer.MAX_VALUE but performance may be better if the actual maximum number of results you want is specified. SortComparatorSource is replaced by FieldComparatorSourceImplementations of the NavigableField interface must now return a FieldComparatorSource from the getSortComparatorSource() method. The FieldComparator interface, which is returned by a FieldComparatorSource, is quite different from the previous SortComparator, but as most abstract implementations of NavigableField already implement this method, it is unlikely to effect most plugin developers. JIRA API Changes in JIRA 5.0 (from JIRA 4.4)Changes in JIRA 5.0's core Java libraries, which differ from JIRA 4.4.x (and earlier), are indicated in our Clirr report. This report is likely to change throughout the development of JIRA 5.0. Hence, if you are updating or developing plugins for JIRA 5.0, you may wish to check this page periodically. JIRA 5.0 REST APIRefer to our REST API documentation for a list of the latest REST APIs available in JIRA 5.0. Removal of OSUserWith the introduction of Embedded Crowd in JIRA in 4.3, many methods which referred to the old org.opensymphony.user.User and org.opensymphony.user.Group classes were deprecated and a thin emulation layer implemented to allow a simplified transition for plugin developers to the new Crowd User and Group classes. In JIRA 5.0, this emulation layer has been removed. Consequently, org.opensymphony.user.User and org.opensymphony.user.Group and a small number of supporting classes have been removed. Furthermore, all deprecated methods have been either changed to use the new Crowd User and Group classes or removed (where they were simply duplicated by new Crowd versions). Most plugins should just need recompiling. Special CasesThe OpenSymphony Group class had methods for getting the members of the group and for adding and removing members. The OpenSymphony User class had similar methods for finding the groups a user was a member of. Use the new GroupManager component for getting members of a group or adding user to a group. For more low-level manipulation of groups and memberships use the CrowdService component. Changed ExceptionsExceptions thrown by some methods may have changed. Hence, plugin developers will need to adjust their code accordingly. OpenSymphony classes generally threw EntityNotFoundException when a user or group was not found. The Crowd implementation will return null if a user or group is not found. So in places where you caught EntityNotFoundException, you will now need to test the return value for null. Removal of PortletsJIRA 4.0 introduced gadgets to replace the old portlets that were used in earlier versions of JIRA. From JIRA 4.0, we still shipped all the code for portlets to:
In JIRA 5.0, we've finally removed all portlet-specific code from JIRA plugin points and APIs. Some plugins implement upgrade tasks to convert portlets to gadgets. These upgrade tasks may now fail if they depend on portlet specific APIs. These upgrade tasks should either be removed (since upgrading to JIRA 4.0+ should have removed portlets already anyway), or rewritten so that they do not rely on the portlet API. |
| Document generated by Confluence on Aug 18, 2011 23:24 |